package com.projectx.action.chat.GroupAnnocement;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.projectx.R;
import com.projectx.action.chat.GroupChatActivity;
import com.projectx.util.ActivityManage;

public class AnnouncementActivity extends AppCompatActivity {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityManage.addActivity("AnnouncementActivity",this);
        setContentView(R.layout.activity_announcement);
        try {
            getSupportActionBar().hide(); //去除标题栏
        } catch (NullPointerException e){
            Log.d("KMH","没有状态栏标题");
        }
        final ImageView back=findViewById(R.id.back);
        final Button yes=findViewById(R.id.yes);
        final ImageView change=findViewById(R.id.change);
        final TextView content=findViewById(R.id.content);
        final EditText editText=findViewById(R.id.content1);
        String text= getIntent().getStringExtra("content");
        content.setText(text);
        if (true){
            change.setVisibility(View.VISIBLE);
            change.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    content.setVisibility(View.GONE);
                    yes.setVisibility(View.VISIBLE);
                    editText.setText(content.getText());
                    editText.setVisibility(View.VISIBLE);
                }
            });
        }
        yes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                yes.setVisibility(View.GONE);
                content.setText(editText.getText().toString());
                editText.setVisibility(View.GONE);
                content.setVisibility(View.VISIBLE);
                //数据库操作
            }
        });
       back.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               ActivityManage.exitActivity("AnnouncementActivity");
           }
       });
    }
}
